home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / tsr4c.zip / ASCIC.C < prev    next >
Text File  |  1994-02-02  |  3KB  |  102 lines

  1. /********************************************************************
  2.         PopASC  (c) Copyright 1992-94 by Omega Point, Inc.
  3. *********************************************************************/
  4.  
  5. #include "cr.h"
  6.  
  7. #ifdef K1        /* EMS support to create ASCEMS.EXE */
  8. #include "lm.h"        /* which allows move_to_lim() feature */
  9. #endif
  10.  
  11. /****************************************************************************
  12.         INITIALIZATION CODE - main()
  13. *****************************************************************************
  14.  
  15. This module contains initialization code for the resident program.
  16. It is not linked as OBJ file but rather as a library file in order to
  17. assure it gets placed at the end of code segment. No other permanent
  18. code should be written inside this module (like isr()).
  19. Dummy function label init_code_beg marks the start of init code.
  20. Similar data marker init_data_end is declared in the first user C-module 
  21. ASCID.C and is called init_data_end.
  22.  
  23. In order to ENABLE data/code space COMPACTION before going resident
  24. main() should place addresses of these markers into predefined variables
  25. icode_beg,idata_end. The Runtime R0/R1.OBJ will then discard code/data
  26. items used only on initialization. Either of the two code/data compactions
  27. may be enabled separately.
  28.  
  29. ***************************************************************************/
  30.  
  31.  
  32.  
  33. /** STARTUP DATA are in ASCID.C  (discarded in resident mode) **/
  34.  
  35. extern char loaded_msg[],hello_msg[]; /* Startup messages */
  36. extern char removed_msg[],cant_msg[];
  37. extern char hello_atr[];
  38.  
  39. extern word init_data_end;          /* Marks end of init-data */
  40.  
  41.  
  42. /** RESIDENT CODE STACK SPACE **/
  43.  
  44. #define STK_SZ (100)      /* Size in words */
  45. word res_stack[STK_SZ+1]; /* Allow allways extra word ! */
  46.  
  47. extern isr();        /* Interrupt service in ASC.C */
  48. extern word hk_list[];  /* This is in ASC.C for use by isr() function */
  49.  
  50.  
  51. /** Display Signon screen **/
  52.  
  53. signon()
  54. {
  55.   int x0,y0,dx,dy;
  56.    vid_atr=7; clr_scr();
  57.    x0=crs_x=10; y0=crs_y=3;
  58.      dspf(hello_msg,hello_atr);
  59.    dx=crs_x-x0+2; dy=crs_y-y0+3;
  60.    crs_x=x0-1; crs_y=y0-1;
  61.      dsp_box(dx,dy,0x103);
  62.    crs_x=0; crs_y=22; 
  63.      mv_crs();
  64.    vid_atr=0x7;
  65. }
  66.  
  67.  
  68. main()
  69. { char *s=cmd_line;
  70.  
  71.   signon();
  72.   if (second_load())         /* Check if program already loaded */
  73.     {
  74.     up_case(s);    /* Convert command line to upper case */
  75.     if (str_pos('U',s))        /* Command line /U to unload TSR */
  76.       {
  77.       if (remove_tsr())        /* Remove it from memory */
  78.         dspf(removed_msg);    /* Removed Ok */
  79.       else dspf(cant_msg);    /* Cannot remove (not last TSR) */
  80.       }
  81.     else
  82.       dspf(loaded_msg);    /* If so, display error message (in ASCID.C) */
  83.         
  84.     return(1);        /* Exit to DOS with errorlevel 1 */
  85.     }
  86.  
  87.  /* SWITCH TO RESIDENT OPERATION */
  88.  
  89.   idata_end=&init_data_end;    /* This enables init data disposal. */
  90.   icode_beg=signon;        /* This enables init code disposal. */
  91.  
  92.   stay_resident(res_stack,STK_SZ*2);    /* Define TSR stack */
  93.   install_hk(hk_list,isr,STK_SZ*2,3);    /* Install HOT-KEY Support */
  94.  
  95.  
  96. #ifdef K1            /* LIM support for PDK-1 users */
  97.   move_to_lim(1,1,MOVE_BOTH);    /* Moves TSR to EMS if available */
  98. #endif
  99.   return(0);                /* Exit code 0=Ok exit */
  100.  
  101. }
  102.